<template>
  <el-radio-group v-model="data" v-bind="$attrs" v-on="$listeners">
    <el-radio v-for="item in options"
      :key="item[valueKey]"
      :disabled="item.disabled"
      :label="item[valueKey]">
      {{ item[labelKey] }}
    </el-radio>
  </el-radio-group>
</template>

<script>
  export default {
    name: 'RadioGroup',
    props: {
      options: {
        type: Array,
        default: () => []
      },
      // 绑定id数组
      value: {
        type: [String, Object, Number]
      },
      labelKey: {
        type: String,
        default: () => 'label'
      },
      valueKey: {
        type: String,
        default: () => 'value'
      }
    },
    data () {
      return {
        data: undefined
      }
    },
    watch: {
      value: {
        immediate: true,
        handler (newV) {
          this.data = newV
        }
      }
    }
  }
</script>

<style scoped>

</style>
